<template>
	<div>
		<aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig">
			<template v-slot:isEffective="{ row }">
        
				<el-switch
					:model-value="row.isEffective"
					class="ml-2"
					inline-prompt
					@click.native="onChange(row, 'isEffective')"
					:active-value="1"
					:inactive-value="0"
					style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
					active-text="有效"
					inactive-text="无效"
				/>
			</template>
		</aplid-base-crud>
	</div>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import apiMod from '@/apiMod/index'
const crud = ref(null)
let onChange = (row, prop) => {
	// 拿到深拷贝的数据取反
	let btnVal = Object.freeze(JSON.parse(JSON.stringify(row.isEffective)))
	if (btnVal == 0) {
		btnVal = 1
	} else {
		btnVal = 0
	}
	let data = {
		...row,
		isEffective: btnVal,
		createTime: undefined,
		createUserId: undefined,
		createUserName: undefined,
		delFlag: undefined,
		updateTime: undefined,
		updateUserId: undefined,
		updateUserName: undefined,
	}
	apiMod.dataManagementSettings_edit(data).then((res) => {
		crud.value!.refreshChange()
		console.log('修改成功')
	})
}
</script>
<style scoped lang="scss"></style>
